﻿@model Zor_Web.Models.Base.V_Zor_CertificateStart
@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>完税证领用</title>
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script language='javascript' src='~/Content/layer/layer.js'></script>
    <!-- 日期选择器 -->
    <script src="~/Content/laydate/laydate.js"></script>

</head>
<body class="gray-bg">
    <div class="layui-tab layui-tab-brief main-tab-container ">
        <div class="col-sm-12 ct-padding">
            <div class="col-sm-9 ct-padding">
                <button id="btnCancel" class="layui-btn layui-btn layui-btn-small"><span class="glyphicon glyphicon-play"></span> 启用</button>
                <button id="btnSearch" class="layui-btn layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span> 查询</button>
                <button id="btnReplace" class="layui-btn layui-btn-blue layui-btn-small"><span class="glyphicon glyphicon-refresh"></span> 刷新</button>
            </div>
        </div>
        <div class="layui-tab-content">
            <table class="layui-table" lay-skin="line">
                <thead>
                    <tr>
                        <th hidden></th>
                        <th></th>
                        <th>领用人</th>
                        <th>部门名称</th>
                        <th>起始完税证号</th>
                        <th>结束完税证号</th>
                        <th>当前完税证号</th>
                        <th>状态</th>
                        <th>字轨</th>
                        <th>填用</th>
                        <th>作废</th>
                        <th>结存</th>
                        <th>创建日期</th>
                    </tr>
                </thead>
                <tbody id="accordion">
                    @foreach (var item in Model.PageData)
                    {
                        <tr>
                            <td hidden>@item.Certificate_Id</td>
                            <td><input type="radio" name="chk" id="@item.Certificate_Id" value="@item.Certificate_Id" /></td>
                            <td>@item.User_RealName</td>
                            <td>@item.Dt_Name</td>
                            <td>@item.Certificate_StartTaxNum</td>
                            <td>@item.Certificate_EndTaxNum</td>
                            <td>@item.Certificate_NowTaxNum</td>
                            <td>@item.Certificate_StateName</td>
                            <td>@item.Certificate_Zigui</td>
                            <td>@item.Certificate_FillIn</td>
                            <td>@item.Certificate_Invalid</td>
                            <td>@item.Certificate_Balance</td>
                            <td>@TimeHelper.TimeStampToDateTime(item.Certificate_CreateTime.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                        </tr>
                    }
                </tbody>
            </table>

        </div>
        <div class="col-sm-12">
            <div class="col-sm-10">
                @Html.Pager(Model.PageData, new PagerOptions { PageIndexParameterName = "index", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>", PagerItemWrapperFormatString = "<li>{0}</li>" }, new { id = "bootstrappager", @class = "pagination" })
            </div>
            <div class="col-sm-2 to-righjt">
                共 @Model.PageData.TotalItemCount 条记录，页 @Model.PageData.CurrentPageIndex/@Model.PageData.TotalPageCount
            </div>
        </div>
    </div>

    @using (Html.BeginForm("Zor_CertificateStart", "Base", new RouteValueDictionary { { "Model", Model } }, FormMethod.Get))
    {
    <!-- 查询模态框 -->
        <div id="myModalSearch" hidden data-backdrop="static">
            <div id="divfrom" class="layui-tab-content">
                <form class="form-horizontal m-t">
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">创建日期：</label>
                        <div class="col-sm-8">
                            <input id="Certificate_CreateTime" class="form-control layer-date laydate-icon" onclick="laydate({ istime: false, format: 'YYYY-MM-DD' })" name="Certificate_CreateTime" value="@Model.Certificate_CreateTime">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">领用人：</label>
                        <div class="col-sm-8">
                            <input id="Dt_Name" type="text" class="form-control" name="Dt_Name" value="@Model.Dt_Name">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">状态：</label>
                        <div class="col-sm-8">
                            <select name="Certificate_StateName" class="form-control">
                                <option value="@Model.Certificate_StateName">全部</option>
                                <option value="@Model.Certificate_StateName">已启用</option>
                                <option value="@Model.Certificate_StateName">已停用</option>
                                <option value="@Model.Certificate_StateName">已用完</option>
                                <option value="@Model.Certificate_StateName">未启用</option>
                            </select>
                        </div>
                    </div>

                </form>
                <div class="box-footer">
                    <button type="submit" class="layui-btn layui-btn-normal layui-btn-small pull-right">
                        <i class="fa fa-search"></i>查询
                    </button>
                </div>
            </div>
        </div>
    }
</body>
</html>
<script>

    /**
    * 刷新
    **/
    $(function () {
        $("#btnReplace").click(function () {
            Replace();
        })
    })

    //查询
    $(function () {
        $("#btnSearch").click(function () {
            ClearWebControls(divfrom);
            LayerOpen('550px', '250px', '查询条件', $('#myModalSearch'));
        })
    })


    /**
    * 完税证启用
    */
    $(function () {
        $("#btnCancel").click(function () {
            var checkId = CheckboxValueIDs();
            var StartTaxNum = getTableCell(4);            
            var EndTaxNum = getTableCell(5);
            if (checkId.length == 0) {
                layer.msg("请选择要启用的完税证号！");                                                             //未选中任何行
                return;
            }
            else {
                layer.confirm("确定要启用吗?", { icon: 2, btn: ['确定', '取消'] }, function () {                    
                    ZorPostSimpleData("/Base/CertificateStarted", JSON.stringify({ "id": checkId[0], 'StartTaxNum': StartTaxNum, 'EndTaxNum': EndTaxNum }), function (data) { //获取数据(带参数)
                        if (data.AnswerType == 1)
                            Replace();
                        layer.msg(data.AnswerMeg);
                    })
                })
            }
        })
    })

</script>